Part Number Hot Search : 
SMCJ30A AN731 BR1010 15P1S5ZE TD62104F 00511 S7908D NC7SP05
Product Description
Full Text Search
 

To Download AN2752 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  august 2011 doc id 14651 rev 5 1/40 AN2752 application note getting started with the stm8s and stm8a introduction this application note complem ents the information in the stm8s and stm8a datasheets by describing the minimum hardware and software environment required to build an application around an stm8s and stm8a 8-bit microcontroller device. it is divided into the following sections: power supply analog-to-digital converter (adc) clock management reset control and development debugging tool support stm8 software toolchain setting up the stm8 development environment this application note also contains detailed re ference design schematics with descriptions of the main components. in addition, some hardware recommendations are given. www.st.com
contents AN2752 2/40 doc id 14651 rev 5 contents 1 hardware requirements summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2 power supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.1 power supply overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.2 main operating voltages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.3 power-on/power-down reset (por/pdr) . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3 analog-to-digital conver ter (adc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.1 analog power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.2 analog input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 4 clock management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4.1 clock management overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4.2 internal clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4.3 external clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 5 reset control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 5.1 reset management overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 6 recommendations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 6.1 printed circuit board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 6.2 component position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 6.3 ground and power supply (v ss , v dd ) . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 6.4 decoupling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 6.5 other signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 6.6 unused i/os and features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 6.7 user options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 7 reference design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 7.1 components reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 7.2 schematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 8 stm8 development tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
AN2752 contents doc id 14651 rev 5 3/40 8.1 single wire interface module (swim) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 8.1.1 swim overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 8.1.2 swim connector pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 8.1.3 hardware connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 8.2 emulator stice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 8.2.1 stice overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 8.2.2 stice in emulation configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 8.2.3 in-circuit programming and debugging . . . . . . . . . . . . . . . . . . . . . . . . . 23 9 stm8 software toolchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 9.1 integrated development environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 9.2 compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 9.3 firmware library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 10 setting up the stm8 developm ent environment . . . . . . . . . . . . . . . . . 28 10.1 installing the tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 10.2 using the tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 10.2.1 project editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 10.2.2 online help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 10.3 running the demonstration software . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 10.3.1 compiling the project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 10.3.2 selecting the correct debug instrument . . . . . . . . . . . . . . . . . . . . . . . . . 33 10.3.3 connecting the hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 10.3.4 starting the debug session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 10.3.5 running the software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 10.3.6 follow up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 11 documentation and online suppor t . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 12 revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
list of tables AN2752 4/40 doc id 14651 rev 5 list of tables table 1. component list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 table 2. swim connector pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 table 3. document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
AN2752 list of figures doc id 14651 rev 5 5/40 list of figures figure 1. power supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 figure 2. external capacitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 figure 3. typical layout of v dd /v ss pair . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 figure 4. analog input interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 figure 5. system clock distribution internal clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 figure 6. clock sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 figure 7. reset management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 figure 8. output characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 figure 9. input characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 figure 10. reference design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 figure 11. debug system block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 figure 12. hardware connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 figure 13. connection description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 figure 14. stice in emulation configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 figure 15. in-circuit programming and debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 4 figure 16. stm8 software toolchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 figure 17. stm8 firmware library examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 figure 18. stvd open example workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 9 figure 19. stvd mcu edit mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 figure 20. stm8 firmware library online help manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 figure 21. stvd: building the project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 figure 22. stvd: selecting the debug instrument. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3 figure 23. connecting the debug instrument to the stm8 evaluation board. . . . . . . . . . . . . . . . . . . . 34 figure 24. stvd: starting the debug session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 figure 25. stvd: run the software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 figure 26. stm8 evaluation board. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
hardware requirements summary AN2752 6/40 doc id 14651 rev 5 1 hardware requirements summary in order to build an application around an stm8s or stm8a device, the application board should, at least, provide the following features: power supply clock management reset management debugging tool support: single wire interface module (swim) connector
AN2752 power supply doc id 14651 rev 5 7/40 2 power supply 2.1 power supply overview the device can be supplied through a 3.0 v to 5.5 v external source. an on-chip power management system provides the 1.8 v digital supply to the core logic, both in normal and low power modes. it is also capable of detecting voltage drops, on both main external (3.3 v/5 v) and internal (1.8 v) supplies. the device provides: one pair of pads v dd /v ss (3.3 v 0.3 v to 5 v 0.5 v) dedicated to the main regulator ballast transistor supply. two pairs of pads dedicated for v dd_io /v ss_io (3.3 v 0.3 v to 5 v 0.5 v), which are used to power only the i/o?s. on 32-pin packages, only one pair is bonded. note: for v ddio /v ssio next to v dd /v ss , it is recommended to connect these two pairs together and to use only one decoupling capacitance. th e purpose is to ensure good noise immunity by reducing the connection length between both supplies and also between v dd /v ddio and the capacitor. one pair of pads v dda /v ssa (3.3 v 0.3 v to 5 v 0.5 v) dedicated to analog functions. refer to section 3: analog-to-digital converter (adc) on page 10 for more details. figure 1. power supply note: the capacitors must be connected as close as possible to the device supplies (especially v dd in case of dedicated ground plane). placing a crystal/resonator on oscin/oscout is option al. the resonator must be connected as close as possible to the osci n and oscout pins. the loading capacitance ground must be connected as close as possible to v ss . m a in / low power reg u l a tor cpu ram logic an a log f u nction s io s io s xtal s t a r connected an a log s ign a l v cap v dd /v ddio1 v ddio2 v ss io2 v dda v ss a o s cin o s cout v ddio v ss io v ss io v ddio 3 . 3 v - 5v v ss /v ss io1 a i15 33 0
power supply AN2752 8/40 doc id 14651 rev 5 2.2 main operating voltages stm8s and stm8a devices are processed in 0.13 m technology. the stm8s and stm8a core and i/o peripherals need different power supplies. in fact, stm8s and stm8a devices have an internal regulator with a nominal target output of 1.8 v. stabilization for the main regulato r is achieved by connecting an external capacitor c ext to the vcap pin. please refer to the stm8s or stm8a datasheets for more information on the vcap capacitor characteristics. care should be taken to limit the series inductance to less than 15 nh. figure 2. external capacitor 2.3 power-on/power-down reset (por/pdr) the input supply to the main and low power regulators is monitored by a power-on/power- down reset circuit. the monitoring voltage range is 0.7 v to 2.7 v. during power-on, the por/pdr keeps the device under reset until the supply voltages (v dd and v ddio ) reach their specified working area. at power-on, a defined reset should be maintained below 0.7 v. the upper threshold for a reset release is defined in the electrical characteristics section of the product datasheet. a hysteresis is implemented (por > pdr) to ensure clean detection of voltage rise and fall. the por/pdr also generates a reset when the supply voltage drops below the v por/pdr threshold (isolated and repetitive events). c rleak esr esl where: esr is the equivalent series resistance esl is the equivalent inductance
AN2752 power supply doc id 14651 rev 5 9/40 recommendations all pins need to be properly connected to the power supplies. these connections, including pads, tracks and vias should have the lowest possible impedance. this is typically achieved with thick track widths and preferably dedicated power supply planes in multi-layer printed circuit boards (pcbs). in addition, each power supply pair should be decoupled with filtering ceramic capacitors (c) at 100 nf with one chemical c (1..2 f) in parallel on the stm8s or stm8a device. the ceramic capacitors should be placed as close as possible to the appropriate pins, or below the appropriate pins, on the opposite side of the pcb. typical values are 10 nf to 100 nf, but exact values depend on the application needs. figure 3 shows the typical layout of such a v dd /v ss pair. figure 3. typical layout of v dd /v ss pair via to v ss via to v dd cap . v dd v ss stm8
analog-to-digital converter (adc) AN2752 10/40 doc id 14651 rev 5 3 analog-to-digital converter (adc) 3.1 analog power the adc unit has an independent, analog supply reference voltage, isolated on input pin v dda , which allows the adc to accept a very clean voltage source. this analog voltage supply range is the same as the digital voltage supply range on pin v dd . an isolated analog supply ground connection on pin v ssa provides further adc supply isolation. together, the analog supply voltage and analog supply ground connection, offer a separate external analog reference voltage input for the adc unit on the v ref+ pin. this gives better accuracy on low voltage input as follows: v ref+ (input, analog reference positive): the higher/positive reference voltage for the adc should be between [250 mv, v dda ]. for more details about v ref+ values please refer to the stm8s or stm8a datasheets. this input is bonded to v dda in devices that have no external v ref+ pin (packages with 48 pins or less). v ref- (input, analog reference negative): the lower/negative reference voltage for the adc should be higher than v ssa . for more details about v ref- values please refer to the stm8s or stm8a datasheets. this input is bonded to v ssa in devices that have no external v ref- pin (packages with 48 pins or less). 3.2 analog input stm8s and stm8a devices have 16 analog input channels, which are converted by the adc one at a time, and each multiplexed with an i/o. the analog input interface of the adc is shown in figure 4 . figure 4. analog input interface v in_ext r ext c ext c samp sw samp v in outside adc inside adc
AN2752 analog-to-digital converter (adc) doc id 14651 rev 5 11/40 equation 1: where: c vin is the total equivalent capacitor on the path of v in c samp is the equivalent sampling capacitance c ext is the total external capacitance on the path of v in to the macro pin. this includes parasitic routing capacitance, pad and pin capacitance and external capacitance. to ensure proper and accurate sampling the following equation must be satisfied equation 2: where: r sw = 30 kohm r ext is the total external resistance on the path of v in c samp = 3 pf t s = 0.5 s (for 2 mhz input clk) equation 2 is specific for r ext and c ext when designing an analog input interface for the adc. please refer to the stm8s or stm8a datasheets and/or their corresponding reference manual (rm0016) for more details. c vin c samp c ext + = r sw r ext + () c samp c ext + () 3 10 ------ ?? ?? t s <
clock management AN2752 12/40 doc id 14651 rev 5 4 clock management 4.1 clock management overview stm8s and stm8a devices offer a flexible way of selecting the core and peripheral clocks (adc, memory, digital peripherals). the devices have internal and external clock source inputs and one output clock (cco). figure 5. system clock distribution internal clock 4.2 internal clock the rc oscillator has an internal capacitor (c) and an internal resistor ladder (r). stm8s and stm8a devices have two kinds of internal clock: a high speed internal clock (hsi) running at 16 mhz and a low speed internal clock (lsi) running at 128 khz. after reset, the cpu starts with the internal rc (hsi clock signal) divided by 8, i.e. 2 mhz. 4.3 external clock stm8s and stm8a devices can connect to an ex ternal crystal or an external oscillator. note: when no external clock is used, oscin and oscout can be used as general purpose i/os. figure 6 describes the external clock connections. 1 to 24 mhz crystal and external clock 16 mhz/128 khz internal rc prescaler external clock osc out osc in cco pin lnternal clock clock distribution wdg/awu timer clock unit for more details please refer to the section on clock management in the datasheet
AN2752 clock management doc id 14651 rev 5 13/40 figure 6. clock sources the values of the load capacitors c l1 and c l2 are heavily dependent on the crystal type and frequency. the user can refer to the datasheet of the crystal manufacturer to select the capacitances. for best oscillation stability c l1 and c l2 normally have the same value. typical values are in the range from below 20 pf up to 40 pf (cload: 10 ? 20 pf). the parasitic capacitance of the board layout also needs to be considered and typically adds a few pf to the component values. recommendations in the pcb layout all connections should be as short as possible. any additional signals, especially those that could inte rfere with the oscillato r, should be locally separated from the pcb area around the oscillation ci rcuit using suitable shielding. hardware configuration external clock frequency: 32 khz ? 24 mhz comparator hysteresis: 0.1 * v dd caution: without prescaler, a duty cycle of ma ximum 45/55% must be respected crystal/ceramic resonators frequency range: 1-24 mhz wake-up time: < 2 ms @ 24 mhz oscillation mode: preferred fundamental output duty cycle: max 55/45% i/o?s: standard i/o pins multiplexed with osc in and osc out cload: 10 ? 20 pf maximum crystal power: 100 w osc in osc out external source stm8 (i/o available) load capacitors stm8 c l2 c l1 q1 osc in osc out
reset control AN2752 14/40 doc id 14651 rev 5 5 reset control 5.1 reset management overview the reset cell is a dedicated 5 v bidirectional i/o. its output buffer driving capability is fixed to iol min = 2 ma @ 0.4 v in the 3 v to 5.5 v range which includes a 40 k pull-up. output buffer is reduced to the n-channel mosfet (nmos). if a 40 k pull-up is accepted, this cell does not include an output buffer of 5 v capa bility. the receiver includes a glitch filter, whereas the output buffer includes a 20 s delay. there are many reset sources, including: external reset through the nrst pin power-on reset (por) and brown-out reset (bor): during power-on, the por keeps the device under reset until the supply voltage (v dd and v ddio ) reach the voltage level at which the bor starts to function. independent watchdog reset (iwdg) window watchdog reset (wwdg) software reset: the application software can trigger reset swim reset: an external device connected to the swim interface can request the swim block to generate a microcontroller reset illegal opcode reset: if a code to be executed does not correspond to any opcode or prebyte value, a reset is generated electromagnetic susceptibility (e ms) reset: generated if critic al registers are corrupted or badly loaded figure 7. reset management stm8 filter illegal op code reset swim reset ems reset por/bor reset delay vdd_io system reset nrst external reset r pu iwdg/wwdg/software reset pulse generator (min 20 s simplified functional i/o reset schematic
AN2752 reset control doc id 14651 rev 5 15/40 output characteristics a valid pulse on the pin is guaranteed with a 20 ns pulse duration on the internal output buffer. after a valid pulse is recognized, a pulse on the pin of at least 20 s is guaranteed starting from the falling edge of a. figure 8. output characteristics input characteristics all pulses with a duration less than 75 ns are filtered all train/burst spikes with a ratio of 1/10 must be filtered. this means that a negative spike of up to 75 ns is always filtered, wh en a 7.5 ns interval between spikes occurs (ratio 1/10). all pulses with duration more than 450 ns are recognized as valid pulses after a valid pulse is recognized, an internal pulse of at least 30 ns is guaranteed figure 9. input characteristics 20 ns 20 s pulse stretch min a pad reset requested pad system reset >7.5 ns >7.5 ns <75 ns <75 ns <75 ns 450 ns >30 ns reset requested negative train of glitch filtered
recommendations AN2752 16/40 doc id 14651 rev 5 6 recommendations 6.1 printed circuit board for technical reasons, it is best to use a mult i-layer pcb with a separate layer dedicated to the v ss and another layer to the v dd supply, which results in a good decoupling, as well as a good shielding effect. for many applications , economical requirements prohibit the use of this type of board. in this case, the most important feature is to ensure a good structure for the v ss and power supply. 6.2 component position a preliminary layout of the pcb must separate the different circuits according to their electromagnetic interference (emi) contribution in order to reduce cross-coupling on the pcb, i.e. noisy, high-current circuits, low voltage circuits, and digital components. 6.3 ground and power supply (v ss , v dd ) the v ss should be distributed individually to every block (noisy, low level sensitive, and digital) with a single point for gathering all ground returns. loops must be avoided or have a minimum surface. the power supply should be implemented close to the ground line to minimize the surface of the supply loop. this is due to the fact that the supply loop acts as an antenna, and is therefore the main emitter and receiver of emi. all component-free surfaces of the pcb must be filled with additional groundin g to create a kind of shield (especially when usin g single-layer pcbs). 6.4 decoupling the standard decoupler for the external power is a 100 f pool capacitor . supplementary 100 nf capacitors must be placed as close as possible to the v ss /v dd pins of the micro in order to reduce the area of the current loop. as a general rule, decoupling all sensitive or noisy signals improves electromagnetic com - patibility (emc) performances. there are 2 types of decouplers: capacitors close to components. inductive char acteristics, which apply to all capacitors beyond a certain frequency, must be taken into account. if possible, parallel capacitors with decreasing values (0.1, 0.01,... f) should be used. inductors. although often ignored, ferrite beads, for example, are excellent inductors due to their good dissipation of emi energy and there is no loss of dc voltage (which is not the case when simple resistors are used).
AN2752 recommendations doc id 14651 rev 5 17/40 6.5 other signals when designing an application, the following areas should be closely studied to improve emc performances: noisy signals (clock) sensitive signals (high impedance) in addition to: signals for which a temporary disturbance permanently affects operation of the application, for example, interrupts and handshaking strobe signals (but not led commands). a surrounding v ss trace for such signals increases emc performances, as does a shorter length or absence of noisy and sensitive traces (crosstalk effect). for digital signals, the best possible electrical margin must be reached for the 2 logical states. slow schmitt triggers are recommended for eliminating parasitic states. 6.6 unused i/os and features microcontrollers are designed for a variety of applications, where often a particular application does not use 100 % of the microcontroller resources. to increase emc performance, unused clocks, counters, or i/os, should not be left free, for example, i/os should be set to ?0? or ?1? (pull-up or pull-down to the unused i/o pins) and unused functions should be ?frozen? or disabled. alternatively, unused i/os can be programmed as push-pull ?low? in order to keep them at a defined level but not to use external components. 6.7 user options stm8s and stm8a devices have user option features that can be used for remapping or enabling/disabling an automatic reset or low speed watchdog . for more details please refer to the product datasheet.
reference design AN2752 18/40 doc id 14651 rev 5 7 reference design 7.1 components reference table 1. component list id component name reference quantity comments 1 microcontroller stm8s and stm8a 1 refer to the ?pinouts and pin description? and ?package characteristics? sections of the stm8s or stm8a datasheets, to choose the right package 2 push button 1 1 3 resistor 10 kohm 1 4 capacitor 100 nf 5 ceramic capacitor (decoupling capacitor) 5 capacitor 1 f 1 decoupling capacitor 6 capacitor 1 f 1 main regulator stabilization 7 capacitor 20..40 pf 2 used for crystal 8 crystal 1..24 mhz 1 9 swim connector 4 pins 1
AN2752 reference design doc id 14651 rev 5 19/40 7.2 schematics figure 10. reference design 1. if pins 22 or 25 are required as gpio, r1 and r2 should be removed. 2. v dd must be within the allowed supply voltage range of the stm8s or stm8a microcontroller. 1 4 3 2 b1 c1 100 nf c3 20 pf c2 20 pf x1 24 mhz c4 1 f pa1 pa2 c9 1 f 6$$ 2) pf1 pf2 pa0 vcap c5 100 nf c6 100 nf c7 100 nf nrst 1 pa1/osci n 2 pa2/os co ut 3 vss io_1 4 vs s 5 vcap 6 vdd 7 vddio_1 8 pa3/tim2_ch3[tim3_ch1] 9 pa4/uart1_rx 10 pa5/uart1_tx 11 pa6/uart1_ck 12 ph0 13 ph1 14 ph2 15 ph3 16 pf7/ain15 17 pf6/ain14 18 pf5/ain13 19 pf4/ain12 20 pf3/ain11 21 pf2/vre f+ 22 vdda 23 vss a 24 pf1/vre f- 25 pf0/ain10 26 pb7/ain7 27 pb6/ain6 28 pb5/ain5[i2c_s da] 29 pb4/ain4[i2c_scl] 30 pb3/ain3[tim1_ etr] 31 pb2/ain2[tim1_ch3n] 32 pb1/ain1[tim1_ch2n] 33 pb0/ain0[tim1_ch1n] 34 ph4/ti m1_etr 35 ph5/tim1_ch3n 36 ph6/tim1_ch2n 37 ph7/tim1_ch1n 38 pe6/ain9 39 pe7/ain8 40 pe5/spi_ns s 41 pc0/adc_etr 42 pc1/tim1_ch1 43 pc2/tim1_ch2 44 pc3/tim1_ch3 45 pc4/tim1_ch4 46 pc5/s pi_sc k 47 vss io_2 48 vddio_2 49 pc6/s pi_mos i 50 pc7/s pi_mi so 51 pg0/can_t x 52 pg1/can_r x 53 pg2 54 pg3 55 pg4 56 pi 0 57 pi 1 58 pi 2 59 pi 3 60 pi 4 61 pi 5 62 pg5 63 pg6 64 pg7 65 pe4 66 pe3/t im1_b kin 67 pe2/i2c_sd a 68 pe1/i2c_sc l 69 pe0/clk_ cc o 70 pi 6 71 pi 7 72 pd0/tim3_ch2 [tim1_bkin] [clk_ cc o] 73 pd1/sw im 74 pd2/tim3_ch1[tim2_ch3] 75 pd3/tim2_ch2[adc_ etr] 76 pd4/tim2_ch1[bee p] 77 pd5/uart3_tx 78 pd6/uart3_r x 79 pd7/tl i[tim1_ch4] 80 u1 stm8 package l qf p 80- pin 1 2 3 4 cn1 sw im connector debug 6$$ 2) r2 0 0 r1 0 c8 100 nf 6$$ 6$$ 2) mcu decoupling capacitor clock(hse) reset 1) 2) bjd ;=alternatefunctionremappingoption)fthesamealternate functionisshowntwice itindicatesanexclusivechoicenota duplicationofthefunction 
stm8 development tools AN2752 20/40 doc id 14651 rev 5 8 stm8 development tools development tools for stm8s and stm8a microcontrollers include the stice emulation system supported by a complete software tool package including c compiler, assembler and integrated development environment with high-level language debugger. 8.1 single wire interface module (swim) 8.1.1 swim overview in-circuit debugging mode or in-circuit programming mode are managed through a single wire hardware interface based on an open-drain line, featuring ultra fast memory programming. coupled with an in-circuit debugging module, the swim also offers a non- intrusive read/write to ram and peripherals. this makes the in-circuit debugger extremely powerful and close in performance to a full-featured emulator. the swim pin can be used as a standard i/o (with 8 ma capability) which has some restrictions if the user wants to use it for debugging. the most secure way to use it is to provide a strap option on the pcb. please refer to the stm8 swim communication protocol and debug module user manual (um0470) for more swim protocol details. figure 11. debug system block diagram 8.1.2 swim connector pins the swim connector pins consist of 4 pins as described in ta bl e 2 . swim entry 100 khz osc internal rc comm layer cmd decode dm stm8 core peripheral nvm ram dbg table 2. swim connector pins pin number pin name pin 1 v dd pin 2 swim pin pin 3 v ss pin 4 reset
AN2752 stm8 development tools doc id 14651 rev 5 21/40 8.1.3 hardware connection figure 12. hardware connection caution: it is recommended to place the swim header as close as possible to the stm8s or stm8a device, as this minimizes any possible signal degradation caused by long pcb tracks. 8.2 emulator stice 8.2.1 stice overview the stice is a modular, high-end emulator system which connects to the pc via a usb interface, and to the application board in place of the target microcontroller. it is supported by the free stm8 toolset: ide st visual develop (stvd) programmer, st visual programmer (stvp) and stm8 assembler. please refer to the stice emulator for stm8 for more details. figure 13. connection description 4 4 1 1 2 3 2 3 ad/icc swim adapter application board stm8 swim cable v dd v dd swim connector connection flex connection adapter adapter socket emulation system
stm8 development tools AN2752 22/40 doc id 14651 rev 5 emulation system: stice emulator box cables for usb, power supply, trigger, analyzer input connection flex 60-pin or 120-pin cable for connection to the application board connection adapter links the connection flex to the footprint of the stm8s or stm8a microcontroller adapter socket package-specific socket for connection adapter and stm8s or stm8a microcontroller 8.2.2 stice in emulation configuration in emulation configuration, the stice is connected to the pc via a usb interface and to the application board in place of the target microcontroller being used. connection flex: flexible cable (60-pin or 120-pin depending on the target microcontroller) that rela ys signals from the stice to the application board connection adapter: links the connection flex to the footprint of the target microcontroller on the users application board. adapter socket: socket that solders to the application board in place of the microcontroller and receives the connection adapter. the above accessories are not included with the stice system. to determine exactly what is required for any supported microcontroller, refer to the online product selector on www.st.com .
AN2752 stm8 development tools doc id 14651 rev 5 23/40 figure 14. stice in emulation configuration 8.2.3 in-circuit programming and debugging in the in-circuit debugging/programming configuration, stice allows the application to be programmed in the microcontroller and for the application to be debugged while it runs on the microcontroller on the application board. stice supports the swim protocol, making it possible to in-circuit program and debug the microcontroller using only one general purpose i/o. in both the emulation and the in-circuit programming/debugging configuration, stice is driven by the st visual develop (stvd) or st visual programmer (stvp) integrated development environment running on the host pc. this provides total control of advanced application building, debugging and programming features from a single easy-to-use interface. free st/stm8 toolset: stvd and stvp running on your pcdrive stice stice-sysxxx: includes all emulation resources, meb, teb, and peb cf/fpxxx: connection flex to connect to application board ad/xxxx: connection adapter to link connection cable to microcontroller as/xxxx: adapter socket on application board to plug in emulator in place of microcontroller
stm8 development tools AN2752 24/40 doc id 14651 rev 5 figure 15. in-circuit programming and debugging (swim protocol for stm8, or icc protocol icd/icp flat cable connects stice to microcontroller via icd/icp connector on application board st microcontroller on application board for st) swim connector linked to microcontroller
AN2752 stm8 software toolchain doc id 14651 rev 5 25/40 9 stm8 software toolchain in order to write, compile and run the first software on an stm8s or stm8a device, the following components of the software toolchain are required (see figure 16 ): integrated development environment compiler firmware library (optional, used to ease the start-up) figure 16. stm8 software toolchain
stm8 software toolchain AN2752 26/40 doc id 14651 rev 5 9.1 integrated development environment the integrated development environment st visual develop (stvd) provides an easy-to- use, efficient environment for start-to-finish control of application development, from building and debugging the application code to programming the microcontroller. stvd is delivered as part of the free st toolset, which also includes the st visual programmer (stvp) programming interface and the st assembler linker. to build applications, stvd provides seamless integration of c and assembly tool chains for st including the cosmic and raisonance c compilers and the st assembler linker. when debugging, stvd provides an integrated simulator (software) and supports a complete range of hardware tools including the low-cost rlink in-circuit debugger/programmer and the high-end stice emulator. to program applications to an stm8s or stm8a device, the stvd also provides an interface for reading from the microcontroller memories, writing to them and verifying them. this interface is based on the st visual pr ogrammer (stvp), and supports all the target devices and programming tools supported by stvp. the free st toolset for stm8 is available from stmicroelectronics homepage (see www.st.com ). 9.2 compiler stm8s and stm8a devices can be programmed by a free assembler toolchain which is included in the st toolset. as the core is designed for optimized high-le vel-language support, use of a c compiler is recommended! c compilers for stm8 are offered by the th ird party companies cosmic and raisonance. a free version of the c compiler with up to 16 kbytes of generated code is available at: www.cosmic-software.com and www.raisonance.com.
AN2752 stm8 software toolchain doc id 14651 rev 5 27/40 9.3 firmware library the stm8 firmware library is a complete set of source code examples for each stm8 peripheral. it is written in strict ansi-c and it is fully misra c 2004 compliant (see figure 17 ). all examples are delivered with workspace and project definition files for stvd and cosmic c compiler which enables the user to load and compile them easily into the development environment. the examples run on the stmicroelectronics stm8 evaluation board and can be tailored easily to other types of hardware. for additional information on the stm8 firmware library, please contact stmicroelectronics. figure 17. stm8 firmware library examples
setting up the stm8 development environment AN2752 28/40 doc id 14651 rev 5 10 setting up the stm8 development environment the stm8 development environment setup looks different depending on the supplier of the software (sw) and hardware (hw) tools. typical setups are described below for the following sw and hw tools: stm8 c compiler from cosmic st toolset and stm8 firmware library from stmicroelectronics hw debug interface "rlink" from raisonance stm8 evaluation board from stmicroelectronics 10.1 installing the tools all software tools are delivered with a setup wizard which guides the user through the installation process. it is recommended to install the tools in the following order: 1. c compiler 2. st toolset 3. stm8 firmware library the rlink does not need any dedicated softwar e installation in the stm8 development environment because the necessary drivers are delivered with the st toolset. note: these r-link driver s must be launched separately as follows: start/programs/sttoolset/setup/install rlink driver.
AN2752 setting up the stm8 development environment doc id 14651 rev 5 29/40 10.2 using the tools once the tools installation is complete, the st visual develop (stvd) integrated development environment can be launched. the user then has the choice to generate either a new workspace with a new project or to open an existing workspace. if using the stvd for the first time, it is recommended to open an existing project from the stm8 firmware library. the stm8 firmware library includes several examples for each peripheral plus one workspace containing a project which is alread y configured for the dot-matrix-display of the stm8 evaluation board. it is located in the firmware subdirectory \project\cosmic (see figure 18 ). figure 18. stvd open example workspace
setting up the stm8 development environment AN2752 30/40 doc id 14651 rev 5 10.2.1 project editing all project source files are visible and can be edited (see figure 19 ). figure 19. stvd mcu edit mode
AN2752 setting up the stm8 development environment doc id 14651 rev 5 31/40 10.2.2 online help an online help manual is available inside the firmware installation directory (see figure 20 ) to help the user understand the structure of the stm8 firmware library. figure 20. stm8 firmware library online help manual
setting up the stm8 development environment AN2752 32/40 doc id 14651 rev 5 10.3 running the de monstration software to run the demonstration software on the stm8 evaluation board, the project has to be compiled and the correct hw tool must be selected before the debug session can be started. 10.3.1 compiling the project the project can be compiled using the ?build? function in the ?build? menu (see figure 21 ). figure 21. stvd: building the project
AN2752 setting up the stm8 development environment doc id 14651 rev 5 33/40 10.3.2 selecting the correct debug instrument in the example below, the rlink tool is used for communicating via th e swim interface with the on-board debug module of the stm8. the rlink tool can be selected from the ?debu g instrument selection? list in the ?debug instrument settings? dialog (see figure 22 ). figure 22. stvd: selecting the debug instrument
setting up the stm8 development environment AN2752 34/40 doc id 14651 rev 5 10.3.3 connecting the hardware the rlink tool can be connected to the pc by a standard usb connection. it is also powered by the usb interface. on the controller side the connection to the stm8 evaluation board is made by the swim interface cable. the stm8 evaluation board is powered by an external 5 v supply (see figure 23 ). figure 23. connecting the debug instrument to the stm8 evaluation board caution: on the rlink icc/swim adapter board, the ?swim? jumper must be set. if there is no pull-up on the application swim line, the ?adapt? jumper is also set. in any case, ?pw-5v? and ?12mhz? jumpers must not be set. rlink adapter for stm8 swim interface connection 5 v power supply rlink usb connection
AN2752 setting up the stm8 development environment doc id 14651 rev 5 35/40 10.3.4 starting the debug session debug mode can be entered by the command ?debug start debugging? (see figure 24 ). figure 24. stvd: starting the debug session
setting up the stm8 development environment AN2752 36/40 doc id 14651 rev 5 10.3.5 running the software after entering debug mode, the software can be started by the run command in the menu ?debug run? (see figure 25 ). figure 25. stvd: run the software
AN2752 setting up the stm8 development environment doc id 14651 rev 5 37/40 the lcd display on the stm8 evaluation board indicates a successful debug session (see figure 26 ). figure 26. stm8 evaluation board 10.3.6 follow up step by step, additional peripherals of stm8s and stm8a devices can be run, following on from the initial debug session described above. many features of stm8s and stm8a devices are supported by dedicated hardware on the stm8 evaluation board. the necessary software drivers (can driver, lin driver, buttons, memory cards, buzzer, etc) are delivered in the stm8 firmware library.
documentation and online support AN2752 38/40 doc id 14651 rev 5 11 documentation and online support documentation resources related to tool usage includes: application stm8s datasheets: ? stm8s207xx stm8s208xx ? stm8s105xx ? stm8s103k3 stm8s103f3 stm8s103f2 ? stm8s903k3 stm8s903f3 ? stm8s003k3 stm8s003f3 stm8a datasheets: ? stm8af52xx stm8af6269/8x/ax stm8af51xx stm8af6169/7x/8x/9x/ax ? stm8af622x/4x stm8af6266/68 stm8af612x/4x stm8af6166/68 how to program stm8s and stm8a flash program memory and data eeprom (pm0051) stm8s and stm8a microc ontroller families refe rence manual (rm0016) stm8 cpu programming manual (pm0044) tools stm8 firmware library and release note (detailed descriptions of the library are included as help files) stice advanced emulation system for st microcontrollers data briefing stice user manual cosmic c compiler user manual stm8/128-eval evaluation board user manual (um0482) st visual develop tutorial (included as help files in the st-toolchain) st visual develop (stvd) user manual stm8 swim communication protocol and debug module user manual (um0470) the microcontroller discussion forum on www.st.com can be used by developers to exchange ideas. it is the best place to find different application ideas. in addition, the website has a knowledge base of faqs for microcontrollers, which provide answers to many queries and solutions to many problems.
AN2752 revision history doc id 14651 rev 5 39/40 12 revision history table 3. document revision history date revision changes 03-jun-2008 1 initial release 01-sep-2008 2 stm8s207/208 replaced by stm8s20xxx figure 10: reference design on page 19 and figure 12: lqfp 80- pin pinout on page 21 modified to be in line with the pin description of the stm8s20xxx datasheet figure 7: reset management on page 14 modified 01-apr-2009 3 modified section 2.2: main operating voltages on page 8 05-aug-2011 4 table 1: general operating conditions : replaced figure 10: reference design on page 19 : updated the value of the c4 capacitor. 31-aug-2011 5 added stm8a throughout the document as this revision covers stm8a devices. replaced ?root part number 2? with stm8s and stm8a. updated section 2.2: main operating voltages : removed table 1: general operating conditions and added a reference to the stm8s and stm8a datasheets. removed section 5.2: hardware reset implantation . table 1: component list : updated ?reference? value for ?id? 6. removed section 7.3: pinouts . updated references in section 11: documentation and online support
AN2752 40/40 doc id 14651 rev 5 please read carefully: information in this document is provided solely in connection with st products. stmicroelectronics nv and its subsidiaries (?st ?) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described he rein at any time, without notice. all st products are sold pursuant to st?s terms and conditions of sale. purchasers are solely responsible for the choice, selection and use of the st products and services described herein, and st as sumes no liability whatsoever relating to the choice, selection or use of the st products and services described herein. no license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. i f any part of this document refers to any third party products or services it shall not be deemed a license grant by st for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoev er of such third party products or services or any intellectual property contained therein. unless otherwise set forth in st?s terms and conditions of sale st disclaims any express or implied warranty with respect to the use and/or sale of st products including without limitation implied warranties of merchantability, fitness for a parti cular purpose (and their equivalents under the laws of any jurisdiction), or infringement of any patent, copyright or other intellectual property right. unless expressly approved in writing by two authorized st representatives, st products are not recommended, authorized or warranted for use in milita ry, air craft, space, life saving, or life sustaining applications, nor in products or systems where failure or malfunction may result in personal injury, death, or severe property or environmental damage. st products which are not specified as "automotive grade" may only be used in automotive applications at user?s own risk. resale of st products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by st for the st product or service described herein and shall not create or extend in any manner whatsoev er, any liability of st. st and the st logo are trademarks or registered trademarks of st in various countries. information in this document supersedes and replaces all information previously supplied. the st logo is a registered trademark of stmicroelectronics. all other names are the property of their respective owners. ? 2011 stmicroelectronics - all rights reserved stmicroelectronics group of companies australia - belgium - brazil - canada - china - czech republic - finland - france - germany - hong kong - india - israel - ital y - japan - malaysia - malta - morocco - philippines - singapore - spain - sweden - switzerland - united kingdom - united states of america www.st.com


▲Up To Search▲   

 
Price & Availability of AN2752

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X